<template>
  <div class="container">
    <div class="hd">
      <h1 class="page_title">{{branchName}}平面图</h1>
    </div>
    <div>
      <figure style="margin: 0.2em 0.5em;" v-show="showErTong">
        <img style="width:100%;" src="../../assets/img/ertongmap.jpg" />
      </figure>
      <figure style="margin: 0.2em 0.5em;" v-show="showFuChan">
        <img style="width:100%;" src="../../assets/img/fuchanmap.jpg" />
      </figure>
    </div>
    <div v-for="build in buildings" class="weui_cells weui_cells_access" style="margin-top:0;">
      <a class="weui_cell" href="javascript:;" @click="goToFloor(build.buildingId,build.buildingName)">
        <div class="weui_cell_bd weui_cell_primary">
          <p class="am-ft-sm">{{build.buildingCode}} {{build.buildingName}}</p>
        </div>
        <div class="weui_cell_ft am-ft-sm">
        </div>
      </a>
    </div>
    <partial name="footer-copyright"></partial>
  </div>
</template>
<style scoped>
.hd {
  padding: .5em 0;
}

.page_title {
  text-align: center;
  font-size: 20px;
  color: #B86086;
  font-weight: 400;
  margin: 0 5%;
}
</style>
<script>
import _ from 'underscore'

export default {
  name: 'HospBUildingView',
  data: function () {
    return {
      branchNo: '',
      branchName: '',
      showErTong: false,
      showFuChan: false,
      buildings: []
    }
  },
  ready: function () {
    this.branchNo = this.$route.query.branchNo
    if (this.branchNo === '01') {
      this.branchName = '儿童医院'
      this.showErTong = true
    } else {
      this.branchName = '妇产医院'
      this.showFuChan = true
    }
    this.getHospBuilding()
  },
  methods: {
    getHospBuilding: function () {
      var self = this
      this.$ajax.get('GetHospBuilding', 'Hosp', { branchNo: this.branchNo }).then(function (data) {
        if (data.ResultCode === '0') {
          self.buildings = _.map(data.Buildings, function (val) {
            return {
              buildingId: val.BuildingId,
              buildingName: val.BuildingName,
              buildingCode: val.BuildingCode
            }
          })
        }
      })
    },
    goToFloor: function (buildingId, buildingName) {
      this.$router.go({ 'name': 'hospFloor', 'query': { 'buildingId': buildingId, 'buildingName': buildingName } })
    }
  }
}
</script>
